<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<p id="#fragment"></p>
<script>
  promise_test(async t => {
    await test_driver.bless("request full screen", () => {
      return document.documentElement.requestFullscreen();
    });
    const fragment = document.createElement("p");
    fragment.id = "fragment";
    document.body.appendChild(fragment);
    const { type: preType } = screen.orientation;
    const isPortrait = preType.startsWith("portrait");
    const newType = `${isPortrait ? "landscape" : "portrait"}-primary`;
    const p = screen.orientation.lock(newType);
    screen.orientation.onchange = t.unreached_func(
      "change event must not fire"
    );
    window.location.href = "#fragment";
    await p;
  }, "When performing a fragment navigation, the orientation must not change or unlock");
</script>
